package cn.kgm.core.typeHandler.template;

import cn.hutool.extra.template.TemplateConfig;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;

/**
 * @author kappi
 */
public class TemplateConfigTypeHandler extends JacksonTypeHandler {

    public TemplateConfigTypeHandler(Class<?> type) {
        super(type);
    }

    @Override
    protected Object parse(String json) {
        try {
            return getObjectMapper().readValue(json, new TypeReference<TemplateConfig>() {
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
